package com.silverhaze.diamond.client.utils.db.engines;

import com.silverhaze.commons.db.datasource.ObjectEntity;
import com.silverhaze.diamond.client.utils.IdGenerator;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Author: Ivan Babanin
 * Time: 6:38:03
 * Date: 22.05.2008
 * <p/>
 * This part of code is strictly confidential.
 */
public class HistoryEngine {
    private static Map<Long, List<EntityWrapper>> history = new HashMap<Long, List<EntityWrapper>>();

    public static void newItem(ObjectEntity entity) {
        List<EntityWrapper> entityWrapperList = history.get(entity.getId());

        if (entityWrapperList == null) {
            entityWrapperList = new ArrayList<EntityWrapper>();
            history.put(entity.getId(), entityWrapperList);
        }

        entityWrapperList.add(new EntityWrapper(IdGenerator.id(), entity));
    }

    public static List<EntityWrapper> getHistoryForEntity(ObjectEntity entity) {
        return history.get(entity.getId());
    }
}

